

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
//import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
 

import org.apache.log4j.Logger;


public class SqlInterface {

	 private static Connection objSqlConnection; 
	 private static Statement objSqlStatement; 
	 static Logger logger = Logger.getLogger("SqlBaseLogs");  
	 
	 SqlInterface () {
    	try{
         	//logger.debug("Start SQL  static segmet "); 
            Class.forName("org.hsqldb.jdbcDriver");           
            objSqlConnection = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa", "");
            objSqlStatement = objSqlConnection.createStatement();
          	//logger.debug("Stop SQL static segmet ");
        	}
        	catch (Exception e) {
                // print a stack trace if there is an issue
        		logger.error("Excp EssbaseLogin   ", e );
        		System.err.println("Error: " + e.getMessage());         		
    		}    	
	  	}
	  
	 public static int sqlExecuteUpdate ( String strSqlQuery) throws SQLException
	 {
       try {	 
	 		
    	   int it =  objSqlStatement.executeUpdate(strSqlQuery);
    	   return it;
    	   
    	   }
         catch (Exception e)
         {
     		logger.error("Excp SqlStatemnet", e );
    		System.err.println("Error: " + e.getMessage());  
    		return -1;
         }
		 
	 }
 
	 public static void sqlCloseStatement () throws SQLException
	 {
       try {
    	   objSqlStatement.close();
    	   }
         catch (Exception e)
         {
     		logger.error("Excp SqlStatemnet", e );
    		System.err.println("Error: " + e.getMessage());  
         }
		 
	 }
	  
	 public static ResultSet sqlReturnDataSet ( String strSqlQuery) throws SQLException
	 { 
       try {
    	   ResultSet rs = objSqlStatement.executeQuery(strSqlQuery);
    	   return rs;   	       	  	 		    	   
       }
         catch (Exception e)
         {
     		logger.error("Excp SqlStatemnet", e );
    		System.err.println("Error: " + e.getMessage());  
    		return null;
         }
		 
	 }

	 public static void sqlPrintDataSet () {

	 }
	
	 
	 
}
